package com.xyq;

import java.util.ArrayList;
import java.util.LinkedList;

public class LinkedListDemo {
    public static void main(String[] args) {
        LinkedList<String>  list = new LinkedList<>();

        list.addFirst("喔");
        list.addLast("yes");
        list.addLast("niu");
        list.addLast("cao");
        list.addLast("哈");
        list.addLast("嘿");

        String S=list.get(3);//o(n)查询速度慢
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.get(3);//o(1)查询速度快

        String first = list.getFirst();
        System.out.println(first);
        String last = list.getLast();
        System.out.println(last);

        String removeFirst = list.removeFirst();
        System.out.println(removeFirst);
        String removeLast = list.removeLast();
        System.out.println(removeLast);
        System.out.println(list);


         }
}
